# from multiprocessing import Process
# import time
#
#
# def task(name):
#
#     print(f'{name} is running')
#     time.sleep(3)
#     print(f'{name} is done')
#
#
# if __name__ == '__main__':
#
#     p = Process(target=task,args=('怼哥',) ,name='任务1')  # name给进程对象设置name属性
#     p.start()
#     # print(p.pid)  # 获取进程pid号
#     # print(p.name)
#     # time.sleep(1)
#     p.terminate() # 终止(结束)子进程
#     # terminate 与 start一样的工作原理: 都是通知操作系统终止或者开启一个子进程,内存中终止或者开启(耗费时间)
#     # time.sleep(1)
#     # print(p.is_alive())  # 判断子进程是否存活
#     # 只是查看内存中p子进程是否运行.
#     print('===主进程')